<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
use app\common\server\Code;

/**
 * @param $pwd
 * @return string
 */
if(!function_exists('password')){
    function password($pwd){
        if(!$pwd) return '';
        return md5(config('admin.admin_salt').$pwd);
    }
}

if(!function_exists('apiReturn')){
    function apiReturn($code_data=[],$return_data=[],$msg=""){
        if(array_key_exists('code',$code_data)){
            if(!empty($msg)) $code_data['msg'] = $msg;
            if(is_string($return_data)) $code_data['msg'] = $return_data;
            $result = $code_data;
        }else{
            $result = Code::$success;
            if(!empty($msg)) $result['msg']=$msg;
            $result['data']=$return_data;
        }
        return json($result);
    }
}

